package com.gangquan360.smartadmin.module.customer.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.module.customer.dao.CustomerInvoiceInfoDao;
import com.gangquan360.smartadmin.module.customer.domain.dto.CustomerInvoiceInfoDTO;
import com.gangquan360.smartadmin.module.customer.domain.entity.CustomerInvoiceInfoEntity;
import com.gangquan360.smartadmin.util.SmartBeanUtil;

/**
 * [ 客户开票信息 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-08 21:25:37
 * @since JDK1.8
 */
@Service
public class CustomerInvoiceInfoService {

    @Autowired
    private CustomerInvoiceInfoDao customerInvoiceInfoDao;

    
    /**
     * @author wiggin
     * @description 添加
     * @date 2020-03-08 21:25:37
     */
    public ResponseDTO<String> add(CustomerInvoiceInfoDTO addDTO) {
        CustomerInvoiceInfoEntity entity = SmartBeanUtil.copy(addDTO, CustomerInvoiceInfoEntity.class);
        customerInvoiceInfoDao.insert(entity);
        return ResponseDTO.succ();
    }


    /**
     * @author wiggin
     * @description 编辑
     * @date 2020-03-08 21:25:37
     */
    public ResponseDTO<String> update(CustomerInvoiceInfoDTO updateDTO) {
        CustomerInvoiceInfoEntity entity = SmartBeanUtil.copy(updateDTO, CustomerInvoiceInfoEntity.class);
        customerInvoiceInfoDao.updateById(entity);
        return ResponseDTO.succ();
    }


    /**
     * @author wiggin
     * @description 删除
     * @date 2020-03-08 21:25:37
     */
    public ResponseDTO<String> delete(Long id) {
        customerInvoiceInfoDao.deleteById(id);
        return ResponseDTO.succ();
    }

    /**
     * @author wiggin
     * @description  根据ID查询
     * @date 2020-03-08 21:25:37
    */
    public ResponseDTO<CustomerInvoiceInfoDTO> detail(Long id){
        CustomerInvoiceInfoEntity entity = customerInvoiceInfoDao.selectById(id);
        CustomerInvoiceInfoDTO dto =  SmartBeanUtil.copy(entity,CustomerInvoiceInfoDTO.class);
        return ResponseDTO.succData(dto);
    }
}
